package Eyjafjalla.card.attack;

import Eyjafjalla.action.EyjafjallaAttackAction;
import Eyjafjalla.action.RetainCloudAction;
import Eyjafjalla.card.AbstractEyjafjallaCard;
import Eyjafjalla.modcore.EyjafjallaTag;
import Eyjafjalla.patch.CloudPatch;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.DamageAction;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.localization.CardStrings;
import com.megacrit.cardcrawl.monsters.AbstractMonster;

public class FloorCloud_Eyjafjalla extends AbstractEyjafjallaCard {
    public static final String ID = "FloorCloud_Eyjafjalla";
    private static final CardStrings cardStrings;

    public FloorCloud_Eyjafjalla(){
        super(ID, cardStrings.NAME,1,cardStrings.DESCRIPTION,CardType.ATTACK,CardRarity.BASIC,CardTarget.ENEMY);
        this.baseDamage = 7;
        this.damage =7;
        this.baseMagicNumber = 3;
        this.magicNumber = 3;
        this.tags.add(EyjafjallaTag.RETAIN_EYJAFJALLA);
        this.selfRetain = true;
        setFireDescription(cardStrings.EXTENDED_DESCRIPTION[0]);
    }

    @Override
    public AbstractCard makeCopy() {
        return new FloorCloud_Eyjafjalla();
    }

    @Override
    public void use(AbstractPlayer p, AbstractMonster m) {
        addToBot(new EyjafjallaAttackAction());
        addToBot(new DamageAction(m, new DamageInfo(p, this.damage, this.damageTypeForTurn), AbstractGameAction.AttackEffect.SLASH_DIAGONAL));
        if (isFire()) {
            addToBot(new DamageAction(m, new DamageInfo(p, this.damage, this.damageTypeForTurn), AbstractGameAction.AttackEffect.FIRE));
        }
    }

    @Override
    public void onRetained() {
        addToBot(new RetainCloudAction(this));
    }

    @Override
    public void calculateCardDamage(AbstractMonster mo) {
        int trueD = baseDamage;
        if(inCloud()){
            baseDamage+=magicNumber;
        }
        super.calculateCardDamage(mo);
        baseDamage = trueD;
        isDamageModified = baseDamage!=damage;
    }

    @Override
    public void applyPowers() {
        int trueD = baseDamage;
        if(inCloud()){
            baseDamage+=magicNumber;
        }
        super.applyPowers();
        baseDamage = trueD;
        isDamageModified = baseDamage!=damage;
    }

    @Override
    public void triggerOnGlowCheck() {
        this.glowColor = AbstractCard.BLUE_BORDER_GLOW_COLOR.cpy();
        if(inCloud()){
            this.glowColor = AbstractCard.GOLD_BORDER_GLOW_COLOR.cpy();
        }
    }

    @Override
    public void upgrade() {
        if(!this.upgraded){
            upgradeName();
            upgradeDamage(2);
            upgradeMagicNumber(1);
        }
    }

    static {
        cardStrings = CardCrawlGame.languagePack.getCardStrings(ID);
    }
}

